<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
</head>
<body>
<!--<div class="layuimini-container">-->
<div class="layuimini-main">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-xs12">
            <div id="echarts-dataset" style="background-color:#ffffff;min-height:600px;padding: 10px"></div>
        </div>
    </div>


</div>
<!--</div>-->
{include file="public/footer" /}
<script>
    layui.use(['layer', 'echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;
        /**
         * 柱状图
         */
        var echartsDataset = echarts.init(document.getElementById('echarts-dataset'), 'walden');

        var optionDataset = {
            title: {
                text: '当前玩家总数：{$countNum}',
                textStyle: {
                    color: 'red'
                },
                padding: [0, 0, 10, 100]  // 位置
            },
            legend: {
                type: 'plain',  // 图列类型，默认为 'plain'
                top: '1%',  // 图列相对容器的位置 top\bottom\left\right
            },
            tooltip: {
                trigger: 'item',
                formatter: function (params) {
                    if ("{$countNum}" != 0) {
                        return params.name + "<br />" +
                            '数量：' + params.data + '人' + "<br />" +
                            '占比：' + ((parseInt(params.data) / parseInt("{$countNum}")) * 100).toFixed(2) + '%';
                    }
                }
            },
            xAxis: {
                type: 'category',
                axisLabel: {
                    formatter : function(params,val){
                        return params.replace('&middot;','.')+"\n\n数量:"+[{$data}][val]+"人\n占比:"+((parseInt([{$data}][val]) / parseInt("{$countNum}")) * 100).toFixed(2) + '%';
                    }
                },
                data: [{$title}]
            },
            yAxis: {
                type: 'value',
                max: "{$countNum}"
            },
            series: [
                {
                    type: 'bar',
                    data: [{$data}],
                },
            ]
        };
        echartsDataset.setOption(optionDataset);
       /* echartsDataset.on('click', function (params) {
            layer.open({
                type: 2,
                title: params.name,
                shadeClose: true,
                shade: 0.5,
                area: ['100%', '100%'],
                content: '/admin/Member/index?mark=level&level=' + params.dataIndex+1,
                end: function () {
                    location.reload();
                }
            });

        });*/

        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsDataset.resize();
        }

    });
</script>
</body>
</html>
